package com.qinggeng.project.api.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.qinggeng.common.enums.OrdersReturnStatusEnum;
import com.qinggeng.framework.aspectj.lang.annotation.Excel;
import com.qinggeng.project.system.domain.OrdersReturn;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author 吴鹏飞
 * @date 2020/9/5
 */
@Data
public class OrdersReturnDto {
    /** 订单退单ID */
    private Long ordersReturnId;

    /** 退货方式 */
    private int returnType;

    /** 申请原因 */
    private String reason;

    /** 商品名 */
    private String goodsName;

    /** 退款金额 */
    private BigDecimal payment;

    /** 申请时间 **/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     *  状态码
     *  00=未知
     *  10=待付款，20=待发货，30=待收货，40=待评价，50=已完成，
     *  60=已取消，70=支付超时，80=退单中，90=已退单，100=退单失败
     */
    private String statusCode;
    //状态
    private String status;
    /** 订单编号 */
    private String ordersNo;


    public Long getOrdersReturnId() {
        return ordersReturnId;
    }

    public void setOrdersReturnId(Long ordersReturnId) {
        this.ordersReturnId = ordersReturnId;
    }

    public int getReturnType() {
        return returnType;
    }

    public void setReturnType(int returnType) {
        this.returnType = returnType;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public BigDecimal getPayment() {
        return payment;
    }

    public void setPayment(BigDecimal payment) {
        this.payment = payment;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getOrdersNo() {
        return ordersNo;
    }

    public void setOrdersNo(String ordersNo) {
        this.ordersNo = ordersNo;
    }

    public static OrdersReturnDto getOrdersReturnDto(OrdersReturn ordersReturn){
        OrdersReturnDto ordersReturnDto = new OrdersReturnDto();


        ordersReturnDto.setOrdersNo(ordersReturn.getOrdersNo());
        ordersReturnDto.setGoodsName(ordersReturn.getGoodsName());
        ordersReturnDto.setOrdersReturnId(ordersReturn.getOrdersReturnId());
        ordersReturnDto.setPayment(ordersReturn.getPayment());
        ordersReturnDto.setReason(ordersReturn.getReason());
        ordersReturnDto.setReturnType(ordersReturn.getReturnType());
        ordersReturnDto.setCreateTime(ordersReturn.getCreateTime());

        if (ordersReturn.getStatus()== OrdersReturnStatusEnum.退单中.getValue()){
            ordersReturnDto.setStatusCode("80");
            ordersReturnDto.setStatus("退单中");

        }else if (ordersReturn.getStatus()== OrdersReturnStatusEnum.已退单.getValue()){
            ordersReturnDto.setStatusCode("90");
            ordersReturnDto.setStatus("已退单");

        }else if (ordersReturn.getStatus()== OrdersReturnStatusEnum.退单失败.getValue()){
            ordersReturnDto.setStatusCode("100");
            ordersReturnDto.setStatus("退单失败");
            return ordersReturnDto;
        }else {
            ordersReturnDto.setStatus("00");
            ordersReturnDto.setStatusCode("订单异常");
        }

        return ordersReturnDto;

    }
}
